<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="common::common(title='基础数据')">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" ></meta>
</head>
<script type="text/javascript" th:src="@{/js/basic/uploadFile.js}"></script>
<body>
<div id="app">
  <el-container style="margin-top:10px;">
	<el-header>
	    	<el-form ref="form" :model="queryData" label-width="80px">
		    	<el-row :gutter="20">
				  <el-col :span="6">
				  		<el-form-item label="名称">
					  		<el-input  placeholder="请输入名称" v-model="queryData.itemName" clearable>
							</el-input>
						</el-form-item>
				  </el-col>
				  <el-col :span="6">
				  		<el-form-item label="编码">
					  		<el-input placeholder="请输入编码" v-model="queryData.itemCode" clearable>
							</el-input>
						</el-form-item>
				  </el-col>
				  <el-col :span="6">
				  	<el-button type="primary" icon="el-icon-search" @click="query">查询</el-button>
				  </el-col>
				</el-row>
	    	</el-form>
	    </el-header>
	    <el-main style="padding:5px;">
	    	<div style="margin:10px">
				<el-button type="primary" size="medium" icon="el-icon2-cloud-upload" @click="doUpload">上传</el-button>
	    	</div>
	    	<div style="margin:10px;">
	    	  <el-table  
	    	    ref="uploadFileDatagrid" 
	    	    :data="datagrid"
			    tooltip-effect="dark"
			    style="width: 100%;"
			    max-height="300"
			    @row-click="datagridSelect"
			    border
			    highlight-current-row
			    >
			    <el-table-column type="index" width="30"></el-table-column>
				    <el-table-column prop="id" label="id" width="100"> </el-table-column>
				    <el-table-column prop="fileName" label="文件名称"> </el-table-column>
				    <el-table-column prop="saveFileName" label="存取名称" > </el-table-column>
				    <el-table-column prop="filePath" label="存取路径 "> </el-table-column>
				    <el-table-column prop="created" label="上传日期" > </el-table-column>
				    <el-table-column label="操作">
				      <template slot-scope="scope">
				        <el-button
				          size="mini"
				          type="primary"
				          icon="el-icon2-cloud-download"
				          @click="doDownload(scope.$index, scope.row)"> 下载</el-button>
				        <el-button
				          size="mini"
				          type="danger"
				          icon="el-icon-delete"
				          @click="deleteItem(scope.$index, scope.row)"> 删除</el-button>
				      </template>
				    </el-table-column>
			  </el-table>
			</div>
			<div style="margin:10px">
			    <el-pagination
			      :current-page="queryData.page"
			      :page-sizes="[10, 20, 40, 100]"
			      :page-size="queryData.rows"
			      layout="total, sizes, prev, pager, next, jumper"
			      :total="totalNum"
			      @size-change="handleSizeChange"
			      @current-change="handleCurrentChange"
			      @prev-click="handlePrevClick"
			      @next-click="handleNextClick">
			    </el-pagination>
			 </div>
	    </el-main>
	</el-container>
	
 	<el-dialog :visible.sync="dialogConfig.fileDialogVisible" center="true" 
 		  v-loading="fileLoading"
		  element-loading-text="正在上传"
		  element-loading-spinner="el-icon-loading"
    	  element-loading-background="rgba(0, 0, 0, 0.8)">
		<el-upload ref="fileUploader"
		  class="upload-demo"
		  action="saveFile"
		  name="file"
		  :show-file-list="false"
		  :limit="1"
		  :on-success="uploadFileSuccess"
		  :on-error="uploadFileError"
		  accept=".jpg,.png,.avi"
		  :before-upload="beforeUpload"
		  
		  >
		  <el-button size="small" slot="trigger" type="primary">请选择文件</el-button>
		  <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500KB</div>
		</el-upload>
	</el-dialog>
</div>
</body>
</html>